//
//  LBMainViewController.swift
//  JLBWeibo
//
//  Created by 蒋良彪 on 16/7/2.
//  Copyright © 2016年 Color. All rights reserved.
//

import UIKit

class LBMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 自定义tabBar
        let tabBar = LBTabBar()
        tabBar.lbDelegate = self
        setValue(tabBar, forKey: "tabBar")

        // 添加子控制器
        addChildViewController(LBHomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(LBMessageViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(LBDiscoverViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(LBProfileViewController(), title: "我", imageName: "tabbar_profile")
    }

    @objc private func addChildViewController(childViewController: UIViewController, title: String, imageName: String) {
        childViewController.title = title
        childViewController.tabBarItem.image = UIImage(named: imageName)
        childViewController.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        addChildViewController(UINavigationController(rootViewController: childViewController))
    }
    
}

extension LBMainViewController: LBTabBarDelegate {
    func onComposeButtonClick() {
        
    }
}
